#include "tracking.h"

dres bboxes2dres(vector<vector<bbox>> bboxes) {
	dres result;
	int size = 0, n = 0;
	for (int i = 0; i < bboxes.size(); i++)
	for (int j = 0; j < bboxes[i].size(); j++)
		size++;

	result.x = new double[size];
	result.y = new double[size];
	result.w = new double[size];
	result.h = new double[size];
	result.r = new double[size];
	result.fr = new int[size];
	result.nBox = size;
	result.nei = new neighbor[size];
	result.nFrame = bboxes.size();
	for (int i = 0; i < bboxes.size(); i++) {
		for (int j = 0; j < bboxes[i].size(); j++) {
			result.x[n] = bboxes[i][j].val[0];
			result.y[n] = bboxes[i][j].val[1];
			result.w[n] = bboxes[i][j].val[2] - bboxes[i][j].val[0] + 1;
			result.h[n] = bboxes[i][j].val[3] - bboxes[i][j].val[1] + 1;
			result.r[n] = bboxes[i][j].val[4];
			result.fr[n] = i+1;
			n++;
		}
	}
	return result;
}